package com.explorati.LinkedList.LeetCode206;

public class Solution1 {
	public ListNode reverseListNode(ListNode head) {
		if (head == null) {
			return null;
		}
		if (head.next == null) {
			return head;
		}

		ListNode reverse_head_next = reverseListNode(head.next);

//		ListNode reverse_tail = reverse_head_next;
//		while (reverse_tail.next != null) {
//			reverse_tail = reverse_tail.next;
//		}
//		reverse_tail.next = head;
//		head.next = null;

		 head.next.next = head;
		
		 head.next = null;
		return reverse_head_next;

		// ListNode cur = head;
		// if(cur != null){
		// cur.next = null;
		// head = head.next;
		// }
		//
		//
		// ListNode prev = head;
		//
		// while(prev != null){
		// ListNode next = prev.next;
		// prev.next = cur;
		// head = prev;
		// prev = next;
		// }
		//
		// return head;
		//

	}
}
